package com.example.park_management.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.park_management.entity.Constructionprogress_kzx;
import com.example.park_management.service.IConstructionprogressService_kzx;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 泽西
 * @since 2023-12-05
 */
@RestController
@RequestMapping("/constructionprogress")
public class ConstructionprogressController_kzx {


        @Autowired
        private IConstructionprogressService_kzx constructionprogressService;
//新增或更新
        @PostMapping
        public Boolean save(@RequestBody Constructionprogress_kzx constructionprogressKzx) {
                return constructionprogressService.saveConstructionprogress(constructionprogressKzx);
        }

        @DeleteMapping("/{projectID}")
        public Boolean delete(@PathVariable Integer projectID) {
                return constructionprogressService.removeById(projectID);
                }
        @GetMapping
        public List<Constructionprogress_kzx> findAll() {
                return constructionprogressService.list();
        }
        @GetMapping("/{projectID}")
        public Constructionprogress_kzx findOne(@PathVariable Integer projectID) {
                return constructionprogressService.getById(projectID);
                }
        @GetMapping("/page")
        public Page <Constructionprogress_kzx> findPage(@RequestParam Integer pageNum,
                                                        @RequestParam Integer pageSize,
                                                        @RequestParam(defaultValue = "") String projectName,
                                                        @RequestParam(defaultValue = "") String constructionLocation) {
                QueryWrapper<Constructionprogress_kzx> queryWrapper = new QueryWrapper<>();
        if(!"".equals(projectName)){
        queryWrapper.like("projectName",projectName);
        }
        if(!"".equals(constructionLocation)){
        queryWrapper.like("constructionLocation",constructionLocation);
        }
        queryWrapper.orderByDesc("projectID");
                return constructionprogressService.page(new Page<>(pageNum, pageSize),queryWrapper);
                }




        }

